//
//  HMDetailViewController.swift
//  01-SinaWeibo
//
//  Created by 周英培 on 16/5/21.
//  Copyright © 2016年 周英培. All rights reserved.
//

import UIKit
/*
 1.获得跳转控制器的具体是第几个的方法：navigationController?.childViewControllers.count
 2.获得最顶层控制器的标题的方法：navigationController?.childViewControllers.first
 */
class HMDetailViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        //设置导航条标题，在这里显示每个控制器是第几个
        title = "\(navigationController?.childViewControllers.count ?? 0)"
        //设置背景色
        view.backgroundColor = UIColor.whiteColor()
        
//        //设置左边返回按钮
//        let backItem = UIBarButtonItem(imageName: "navigationbar_back_withtext", title: "返回", target: self, action: #selector(back))
//        
//        navigationItem.leftBarButtonItem = backItem
        
        //设置右边按钮，进行控制器的不断跳转
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Next", style: .Plain, target: self, action: #selector(next))
    }
    
    @objc private func next() {
    
        let detatil = HMDetailViewController()
        
        navigationController?.pushViewController(detatil, animated: true)
        
    
    }
    
//    @objc private func back() {
//    
//    navigationController?.popViewControllerAnimated(true)
//    
//    }
    
    
    
}
